package com.boot.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    @GetMapping("/login")
    public String login(){
        System.out.println("*************IndexController.login************");
        return "login";
    }

    @PostMapping("/doLogin")
    public String doLogin(String userName, String password, HttpSession session){

        if("admin".equals(userName) && "123456".equals(password)){
            //user不为空
            session.setAttribute("user",userName);
        }

        return "redirect:/index";
    }

}
